public class Define extends Quaternion {
    private Pairs pair_a;       //名字
    private Pairs pair_dim1;
    private Pairs pair_dim2;
    private Pairs answer;
    private int type;       //0:array/var/val   1:var/val = some
    private int index;

    public Define(Pairs pair_a, Pairs pair_dim1, Pairs pair_dim2, Pairs answer, int type, OP op) {
        super(op);
        this.pair_a = pair_a;
        this.pair_dim1 = pair_dim1;
        this.pair_dim2 = pair_dim2;
        this.answer = answer;
        this.type = type;
    }


    public void solveAnswer(Pairs answer) {
        this.answer = answer;
    }

    public Pairs getAnswer() {
        return this.answer;
    }

    public Pairs getPair_a() {
        return this.pair_a;
    }

    public int getType() {
        return this.type;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Pairs getPair_dim1() {
        return this.pair_dim1;
    }

    public Pairs getPair_dim2() {
        return this.pair_dim2;
    }

    public String toString() {
        if (type == 0) {
            if (pair_dim1 == null) {
                return opToString() + " " + pair_a.getType() + " " + pair_a.getToken() + "\n";
            } else {
                if (pair_dim2 == null) {
                    return opToString() + " " + pair_a.getType() + " " + pair_a.getToken() + "[" + pair_dim1.getValue() + "]" + "\n";
                } else {
                    return opToString() + " " + pair_a.getType() + " " + pair_a.getToken() + "[" + pair_dim1.getValue() + "]" + "[" + pair_dim2.getValue() + "]" + "\n";
                }
            }
        } else {
            return opToString() + " " + pair_a.getType() + " " + pair_a.getToken() + " " + "=" + " " + answer.getToken() + "\n";
        }
    }
}
